home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / itrns211.zip / SRC / ITRANS.H < prev    next >
C/C++ Source or Header  |  1991-11-28  |  13KB  |  397 lines

  1. #ifndef ITRANS_H
  2. #define ITRANS_H
  3.  
  4. /*
  5.  *========================================================================== 
  6.  * Copyright 1991 Avinash Chopde, All Rights Reserved.
  7.  *
  8.  * Permission to use, copy, modify and distribute this software and its
  9.  * documentation for any purpose is hereby granted without fee, provided that
  10.  * the above copyright notice appear in all copies and that both that
  11.  * copyright notice and this permission notice appear in supporting
  12.  * documentation, and that the name of Avinash Chopde not be used in
  13.  * advertising or publicity pertaining to distribution of the software
  14.  * without specific, written prior permission.
  15.  * Avinash Chopde makes no representations about the suitability of this
  16.  * software for any purpose.
  17.  * It is provided "as is" without express or implied warranty.
  18.  *
  19.  * AVINASH CHOPDE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  20.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  21.  * IN NO EVENT SHALL AVINASH CHOPDE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  22.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  23.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  24.  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  25.  * OF THIS SOFTWARE.
  26.  *
  27.  * Author:  Avinash Chopde, 1991
  28.  *        C2 Colonial Drive #4, Andover, MA 01810, USA.
  29.  *
  30.  */
  31.  
  32. /* static char S_RCSID[] = "$Header: e:/itrans/src/rcs/itrans.h 1.10 91/11/28 20:38:42 avinash Exp $"; */
  33.  
  34. #include <stdio.h>
  35. #include "../version.h"
  36.  
  37. #if defined(MSDOS) || defined(sgi)
  38. /* actually, should be included in more places, but many systems
  39.  * are still missing this file...
  40.  */
  41. #include "stdlib.h"
  42. #endif
  43.  
  44. #ifdef SYSV
  45. #include <string.h>
  46. #else
  47. #include <strings.h>
  48. #endif
  49.  
  50. #ifdef sgi
  51. #include <malloc.h>
  52. #endif
  53.  
  54. #if defined(__STDC__) || (PROTO_C)
  55. #   define P(s)    s
  56. #else
  57. #   define P(s) ()
  58. #endif
  59.  
  60. #include <ctype.h>
  61. #define YYDEBUG 1
  62.  
  63. #include "imap.h"
  64.  
  65. #ifdef MSDOS
  66.  
  67. # define PATHSEP    ';'
  68. # define DIRSEP        '\\'
  69. # define PATH_MAX    256
  70.  
  71. #else
  72.  
  73. # include <pwd.h>
  74. # define PATHSEP    ':'
  75. # define DIRSEP        '/'
  76. # define PATH_MAX    1024
  77.  
  78. #endif
  79.  
  80. /* CONVWORD_LEN is the number of characters that will be generated
  81.  * (in TeX or in PostScript) when a single input word is converted
  82.  * Should be large enough to handle the verbose TeX commands,
  83.  * long words in indian languages....
  84.  */
  85. #define CONVWORD_LEN    8192
  86.  
  87. /* somewhere between Jan-July 1991, the first version of this
  88.  * software came out.
  89.  * Supported Devnagari only, under hindi/marathi switches.
  90.  */
  91.  
  92. /* environment variable for all the paths to search for input file.. */
  93. #define ITRANS_PATH    "ITRANSPATH"
  94. #ifdef MSDOS
  95. #define ITRANS_PATH_DEF    "ITRANSPATH=;..\\lib;"
  96. #else
  97. #define ITRANS_PATH_DEF    "ITRANSPATH=:../lib:"
  98. #endif
  99.  
  100. /* the default ifm file to use --- assume devanagari input */
  101. #define DEVN_IFM_FILE    "dvnc.ifm"
  102.  
  103. #define FALSE    0
  104. #define TRUE    1
  105.  
  106. #define NAMELEN        1024
  107. #define LANGS_MAX    (ENDLANG_TOK - ILANG_TOK)
  108. #define FONTS_MAX    (LANGS_MAX + 3)
  109.  
  110. #define LINELEN        1024
  111.     /* max input line len - AFM, IFM files, mainly */
  112.  
  113. #define    VOWEL_TYPE    1
  114. #define    CONSONANT_SINGLE_TYPE    2
  115. #define    CONSONANT_DOUBLE_TYPE    3
  116. #define    SPECIAL_TYPE    4
  117.  
  118. #define    CONSONANT_MANY_TYPE    100
  119. #define CONS_MAX    10
  120.     /* maximum number of (half) consonants allowed.
  121.      * each indian language letter is either a vowel or a
  122.      * list of half consonants followed by a vowel.
  123.      */
  124.  
  125. #define    _I_(ANY_TOK)    ((ANY_TOK)-OFFSET_TOK)
  126.     /* _I_ converts a token from the parser to its index in
  127.      * the 'font_t.enc[_I_()]' array.
  128.      */
  129.  
  130. #define _F_(ANY_TOK)    ((ANY_TOK)-OFFSET_TOK)
  131.     /* _F_ converts a token from the parser to its form in
  132.      * the 'font_t.khadi[someconsonant][_F_()]' array.
  133.      * Note that forms exist only for A_TOK to AHA_TOK.
  134.      * (additional forms exist, such as HALF_FORM which
  135.      * have no corresponding parser token)
  136.      */
  137.  
  138. #define    A_FORM        (_F_(A_TOK))
  139. #define    AA_FORM        (_F_(AA_TOK))
  140. #define    I_FORM        (_F_(I_TOK))
  141. #define    II_FORM        (_F_(II_TOK))
  142. #define    U_FORM        (_F_(U_TOK))
  143. #define    UU_FORM        (_F_(UU_TOK))
  144. #define    RI_FORM        (_F_(RI_TOK))
  145. #define    RII_FORM    (_F_(RII_TOK))
  146. #define    LI_FORM        (_F_(LI_TOK))
  147. #define    LII_FORM    (_F_(LII_TOK))
  148. #define    AY_FORM        (_F_(AY_TOK))
  149. #define    AAY_FORM    (_F_(AAY_TOK))
  150. #define    AI_FORM        (_F_(AI_TOK))
  151. #define    O_FORM        (_F_(O_TOK))
  152. #define    OO_FORM        (_F_(OO_TOK))
  153. #define    AU_FORM        (_F_(AU_TOK))
  154. #define    AM_FORM        (_F_(AM_TOK))
  155. #define    AHA_FORM    (_F_(AHA_TOK))
  156. #define    HALF_FORM    (AHA_FORM + 1)
  157. #define    IMPLICIT_FORM    (AHA_FORM + 2)
  158.  
  159. #define NUMFORMS    (AHA_FORM + 3)
  160.  
  161. /* =================================================================== */
  162. /* PostScript Stuff */
  163.  
  164. /* EMSIZE will be the current font size
  165.  * EM converts given em size to PostScript point size
  166.  */
  167. #define EMSIZE    "EMSIZE"
  168. #define EMTOPS    "EM"
  169.  
  170. /* =================================================================== */
  171. /* TeX Stuff */
  172.  
  173. /* nothing yet */
  174.  
  175. /* =================================================================== */
  176. /* LETTER_T */
  177. /* Used to pass info from the parser to the application routine */
  178.  
  179. typedef struct {
  180.     int        type; /* type - vowel, consonant, or
  181.                * half consonant and another consonant
  182.                */
  183.     int        cons[CONS_MAX];
  184.     char    nolig[CONS_MAX];
  185.             /* normally, cons[i] and cons[i+1] are checked
  186.              * for ligatures, and if one exists, it is used.
  187.              * But, if nolig[i] is TRUE, then no check
  188.              * is made for ligatures, cons[i] is printed
  189.              * using its half form.
  190.              * Naturally, this only applies if n >= 2
  191.              */
  192.     int        n; /* number of consonants in cons */
  193.     int        v;    /* vowel that goes with c1 or c2 - or is standalone */
  194. }   letter_t;
  195.  
  196. /* =================================================================== */
  197. /* PSCHAR_T */
  198. typedef struct {
  199.     /* all units are for a 1 point size char, times 1000 */
  200.     int w; /* char width */
  201.     int llx, lly, urx, ury; /* bounding box */
  202. } pschar_t;
  203.  
  204. /* =================================================================== */
  205. /* COMP_UNIT_T */
  206. /* Each Devnagari Character is a Composite Character.
  207.  * Each composite character is a list of <pcode, deltas> that
  208.  * specify printer the given postscript char pcode, at the given delta.
  209.  * pcode may be IMPLICIT_PSCHAR, implying that this composite char
  210.  * is a complex char (ex: half sa, half ta, yee), and need to get the
  211.  * implicit form the the char.
  212.  * Implicit forms of single chars are directly defined, for multiple
  213.  * forms (as in the above given example) need to compose together
  214.  * all half/implicit forms of the complex char.
  215.  */
  216.  
  217. #define    IMPLICIT_PSCHAR    -1
  218. #define    NO_PSCHAR    -2
  219.  
  220. #define DORG_LL        1
  221. #define DORG_CLR    2
  222.     /* the deltas in comp_unit_t may be specied with
  223.      * respect to the current char origin (DORG_LL), or wrt to the
  224.      * next char origin (DORG_CLR - current-lower-right)
  225.      */
  226.  
  227. typedef struct __comp_unit_t {
  228.     int u_pschar; /* the postscript character code */
  229.           /* may be IMPLICIT_PSCHAR, implies that the entire
  230.            * implicit letter has to be printed out at this
  231.            * point.
  232.            */
  233.     int deltax, deltay;   /* The offset that is to be used
  234.                * to print this character.
  235.                * The offset is wrt to the current position,
  236.                * depends on the value of the  variable dorg.
  237.                * (UNLIKE Adobe's Composite Character
  238.                * defn which is always from char origin)
  239.                * The delta's refer to a char 1 point
  240.                * in size, and the delta's are x1000.
  241.                * If u_pschar == NO_PSCHAR, then
  242.                * no char is printed, just this delta
  243.                * is applied.
  244.                */
  245.     int    dorg; /* specifies whether the offset is wrt current pos
  246.            * or wrt the origin of the character.
  247.            * Is usually DORG_CLR, i.e current pos.
  248.            */
  249.     struct __comp_unit_t* next; /* pointer to the next comp_unit.. */
  250. } comp_unit_t; 
  251.  
  252. int cus_to_ps P((comp_unit_t* cus, /* chain of PostScript Chars to output */
  253.           int fsize, /* font size being used for the chars */
  254.           char pscomm[])); /* the postscript commands returned here */
  255.  
  256. int cus_to_tex P((comp_unit_t* cus, /* chai